import { defHttp } from '@/utils/http/axios';
import { GetPartnerListParams, PartnerModel, UpdatePartnerParams } from './model/partner'
import { BasicFetchResult } from '@/api/model/baseModel'
import { ErrorMessageMode } from '#/axios';

export function getPartnerList(params: GetPartnerListParams, mode: ErrorMessageMode = 'message') {
  return defHttp.get<BasicFetchResult<PartnerModel>>(
    {
      url: '/connection/partners',
      params,
    },
    {
      errorMessageMode: mode
    }
  );
}

export function updatePartner(id: number, params: UpdatePartnerParams, mode: ErrorMessageMode = 'message') {
  return defHttp.patch<PartnerModel>(
    {
      url: `/connection/partners/${id}`,
      params,
    },
    {
      successMessageMode: mode,
      errorMessageMode: mode,
    }
  );
}

export function enter(id: number, mode: ErrorMessageMode = 'message') {
  return defHttp.post(
    {
      url: `/connection/partners/${id}/enter`,
    },
    {
      errorMessageMode: mode,
    }
  );
}
